/**
 * 字块
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default class BlockSc extends cc.Component {
    @property(cc.Sprite)
    sp:cc.Sprite = null
    @property(cc.Label)
    str:cc.Label = null

    @property([cc.SpriteFrame])
    sparr:cc.SpriteFrame[] =[]

    comeId:number = -1 //来源位置
    public right:boolean = false 

    weizhistr:string = '' //空格序号
    selectIndex:number = -1 //选中序号

    onLoad () {
        this.comeId = -1
        this.right = !1
        this.weizhistr = ''
        this.selectIndex = 0
    }

    start () {

    }

    /**
     * 设置节点位置
     */
    setPos(pos:cc.Vec3){
        this.node.position = pos
    }

    /**
     * 设置节点名称
     * @param str 
     */
    setName(str?:string){
        if(str){
            this.node.name = str
        }
    }

    /**
     * 设置底框
     * @param id 
     */
    setSp(id?:number){
        if(this.right == !0 )return
        //console.log('设置底框',id)
        if(id != null || id != undefined){
            this.sp.spriteFrame = this.sparr[id]
            if(id == 1) this.setRight(true)
        }else{
            this.sp.spriteFrame = null
        }
    }

    /**
     * 设置字
     * @param str 
     */
    setStr(str:string){
        this.str.string = str
    }

    /**
     * 答题字块 是否正确
     */
    setRight(isright:boolean){
        this.right = isright
    }
    getRight(){
        return this.right
    }

    setComeId(id:number){
        this.comeId = id
    }
    // update (dt) {}
}
